using System;
using System.Web;

using MetaSapiens.PageMethods;

public class HttpHandlerBehind : IHttpHandler
{
  HttpContext _context;

  public void ProcessRequest(HttpContext context)
  {
    _context = context;
    if (!PageMethodsEngine.InvokeMethod(this, true))
      throw new Exception("Page method not found!");
  }

  public bool IsReusable
  {
    get { return false; }
  }
  
  [PageMethod(true), UrlFormat("~/HttpHandlerBehind.ashx?i={i}")]
  public void SampleMethod(int i)
  {
    _context.Response.ContentType = "text/plain";
    _context.Response.Write("Hello from HTTP handler (code behind). i == "+i);
  }
}